Skip to content

feat: accept api_key= on client, transcriber, and streaming constructors - #231

Merged
ccampbell-aai merged 1 commit into
masterfrom
ccampbell/api-key-constructors
Aug 14, 2026
Merged

feat: accept api_key= on client, transcriber, and streaming constructors#231
ccampbell-aai merged 1 commit into
masterfrom
ccampbell/api-key-constructors

Conversation

@ccampbell-aai

@ccampbell-aai ccampbell-aai commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Adds a direct api_key= path everywhere a user constructs an SDK object, so authenticating no longer requires the global aai.settings.api_key or building a Client(settings=Settings(...)) chain by hand. Strictly additive — every existing call site behaves identically.

  • Client / AsyncClient: settings is now optional (defaults to a copy of the global settings) and api_key= overrides the key on the client's own settings copy. The global settings object is never mutated.
  • Transcriber, AsyncTranscriber, SyncTranscriber, AsyncSyncTranscriber: api_key= builds an owned client with the same lifecycle as the default path. Given alongside client=, the kwarg takes precedence: since a client's credentials are baked into its connection pool at construction, the transcriber derives and owns a new client from a copy of that client's settings with the key replaced — the given client is left untouched and stays the caller's to close.
  • StreamingClient / AsyncStreamingClient: options becomes optional and api_key= is accepted alongside it — the constructor key takes precedence over options.api_key on a copy (the caller's options object is never mutated; all other fields carry over). No credentials at all now raises an actionable ValueError instead of a bare TypeError.
  • The missing-key error message now names all three fixes: the ASSEMBLYAI_API_KEY env var, aai.settings.api_key, and api_key=.

Bumps the version to 0.68.00 (minor).

Tests: 29 new construction-level tests in tests/unit/test_dx.py; full suite 434 passed with the 405 pre-existing tests untouched.

🤖 Generated with Claude Code

Client and AsyncClient take an optional api_key= and make settings=
optional, defaulting to a copy of the global settings; the missing-key
error now names all three ways to supply one.

Transcriber, AsyncTranscriber, SyncTranscriber, and AsyncSyncTranscriber
take api_key= and build their own client from it, keeping the ownership
semantics of the default-constructed client. Passing both client= and
api_key= raises ValueError.

StreamingClient and AsyncStreamingClient take a keyword-only api_key=
and make options= optional; api_key= takes precedence over a key on
options, applied to a copy so the caller's object is never mutated.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ccampbell-aai
ccampbell-aai force-pushed the ccampbell/api-key-constructors branch from 8b1920a to c280e07 Compare August 14, 2026 01:57
@ccampbell-aai
ccampbell-aai merged commit 5e14b4a into master Aug 14, 2026
7 checks passed
@ccampbell-aai
ccampbell-aai deleted the ccampbell/api-key-constructors branch August 14, 2026 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants